import ROSLIB from 'roslib';

// 仅负责 ROS 连接的建立与关闭，以及基础事件绑定
export function createROSClient(url, { onConnection, onError, onClose } = {}) {
  const ros = new ROSLIB.Ros({ 
    url: url,
    // 添加连接选项
    transportLibrary: 'websocket'
  });

  if (onConnection) ros.on('connection', onConnection);
  if (onError) ros.on('error', onError);
  if (onClose) ros.on('close', onClose);

  return ros;
}


